package com.hl.sfzy.service.impl;


import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.hl.sfzy.entity.MyTest;
import com.hl.sfzy.mapper.MyTestMapper;
import com.hl.sfzy.service.MyTestService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class MyTestServiceImpl implements MyTestService {
    @Autowired
    private MyTestMapper myTestMapper;
    @Override
    public int add(MyTest myTest) {
        return myTestMapper.insert(myTest);
    }

    @Override
    public int edit(MyTest myTest) {
        return myTestMapper.updateByPrimaryKeySelective(myTest);
    }

    @Override
    public int remove(Long id) {
        return myTestMapper.deleteByPrimaryKey(id);
    }

    @Override
    public MyTest findById(Long id) {
        return myTestMapper.selectByPrimaryKey(id);
    }

    @Override
    public PageInfo<MyTest> findAll(Integer pageNum, Integer pageSize, MyTest myTest) {
        PageHelper.startPage(pageNum, pageSize);
        List<MyTest> list = myTestMapper.selectAll(myTest);
        PageInfo<MyTest> pageInfo = new PageInfo<>(list);
        return pageInfo;
    }
}
